#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    thread1 = new MyThread;
    thread1->start();
    QThread::sleep(1);

    //将主线程作为发信号者的线程
    //将子线程作为接收信号的线程
    //connect(this,&MainWindow::mySig,thread1->test,&Test::mySlot);
    //connect(this,&MainWindow::mySig,thread1->test,&Test::mySlot,Qt::DirectConnection);
    //connect(this,&MainWindow::mySig,thread1->test,&Test::mySlot,Qt::QueuedConnection);
    //connect(this,&MainWindow::mySig,thread1->test,&Test::mySlot,Qt::BlockingQueuedConnection);
    connect(this,&MainWindow::mySig,thread1->test,&Test::mySlot,Qt::AutoConnection);
    connect(this,&MainWindow::mySig,thread1->test,&Test::mySlot,(Qt::ConnectionType)(Qt::AutoConnection|Qt::UniqueConnection));



}



MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_pushButton_start_clicked()
{
    emit mySig();

    qDebug() << "继续执行...";
}

void MainWindow::on_pushButton_exit_clicked()
{
    thread1->quit();
}
